package com.example.ibeacon_station;

import android.bluetooth.le.ScanResult;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BeaconListViewModel extends ViewModel {
    private MutableLiveData<Map<String,Beacon>> beaconMapLive;

    public MutableLiveData<Map<String,Beacon>> getBeaconMap() {
        if(beaconMapLive==null){
            beaconMapLive = new MutableLiveData<>();
            beaconMapLive.setValue(new HashMap<>());
        }
        return beaconMapLive;
    }

    public void addBeacon(Beacon beacon){
        Map<String,Beacon> map = beaconMapLive.getValue();
        map.put(beacon.getmMacAddress(),beacon);
        beaconMapLive.postValue(map);
    }
}
